package com.xingfly.repository;

import com.xingfly.model.Tag;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

/**
 * Created by SuperS on 2016/12/7.
 */
public interface TagRepository extends JpaRepository<Tag, Long> {
    Tag findByTitle(String title);

    @Query("SELECT t.id FROM Tag t WHERE t.title=:title")
    Long findTagId(@Param("title") String tag);

    @Query("SELECT t FROM Tag t WHERE t.cover is not null")
    List<Tag> findTagsHasCover(Pageable pageable);


}
